<template>
	<view class="page" :style="themeColor">
		<view class="flex align-stretch benben-position-layout flex bindBankC_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex align-center justify-between flex-sub bindBankC_fd0_0'>
				<view class='flex align-center bindBankC_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
					data-url="1">
					<text class='fu-iconfont2  bindBankC_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex align-center'>
					<text class='bindBankC_fd0_0_c1_c0'>欧洲账户</text>
				</view>
				<view class='flex align-center bindBankC_fd0_0_c0'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<!---flex布局flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout bindBankC_flex_1">
			<view class='flex flex-direction flex-wrap align-stretch bindBankC_fd1_0'>
				<text class='flex-sub bindBankC_fd1_0_c0'>填写欧洲银行卡名称</text>
				<input class='flex-sub bindBankC_fd1_0_c1' type="text" placeholder="输入银行卡名称" confirm-type="done"
					:maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
					v-model="yinhangname" />
			</view>
			<view class='flex flex-direction flex-wrap align-stretch bindBankC_fd1_0'>
				<text class='flex-sub bindBankC_fd1_0_c0'>填写欧洲银行账户</text>
				<input class='flex-sub bindBankC_fd1_0_c1' type="number" placeholder="输入您的账户" confirm-type="done"
					:maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="name" />
			</view>
			<view class='flex flex-direction flex-wrap align-stretch bindBankC_fd1_0'>
				<text class='bindBankC_fd1_1_c0'>填写欧洲账户姓名</text>
				<input class='flex-sub bindBankC_fd1_1_c1' type="text" placeholder="请输入您的账户姓名" confirm-type="done"
					:maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
					v-model="bankName" />
			</view>
			<view class='flex flex-direction flex-wrap align-stretch bindBankC_fd1_0'>
				<text class='bindBankC_fd1_1_c0'>填写欧洲账户开户行</text>
				<input class='flex-sub bindBankC_fd1_1_c1' type="text" placeholder="请输入您的账户开户行" confirm-type="done"
					:maxlength="20" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
					v-model="bankCardNumber" />
			</view>
		</view>

		<!---flex布局flex布局结束-->
		<view class="flex align-start justify-center benben-position-layout flex bindBankC_flex_2">

			<button class='bindBankC_fd2_0' @tap.stop="jiebang" v-if="this.myJinBi.is_binding_en_card == 1">解绑</button>
			<button class='bindBankC_fd2_0' @tap.stop="withdrawFunc" v-else>提交</button>

		</view>
		<view :style="{height: '120rpx'}"></view>


	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},


		data() {
			return {
				"name": "",
				"bankName": "",
				"bankCardNumber": "",
				"openingBank": "",
				yinhangname: '',
				xinxi: {},
				myJinBi: {},
				timerId: null
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			this.getmyQian()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {
			this.getmyQian()
		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//绑定欧洲银行
			async withdrawFunc() {
				if (this.timerId) {
					clearTimeout(this.timerId)
				}
				if (!validate(this.yinhangname, 'require')) {
					this.$message.info('银行卡名称不能为空');
					return false;
				}
				if (!validate(this.name, 'require')) {
					this.$message.info('账户不能为空');
					return false;
				}
				if (!validate(this.bankName, 'require')) {
					this.$message.info('账户姓名不能为空');
					return false;
				}
				if (!validate(this.bankCardNumber, 'require')) {
					this.$message.info('账户开户行不能为空');
					return false;
				}
				this.timerId = setTimeout(async () => {
					let res = await this.$api.post(global.apiUrls.bangdingzhanghao, {
						account_type: 4,
						cardname: this.yinhangname,
						account_id: this.name,
						true_name: this.bankName,
						cardbank: this.bankCardNumber
					})
					if (res.data.code != 1) {
						this.$message.info(res.data.msg)
						return
					}
					this.$message.info(res.data.msg)
					setTimeout(() => {
						this.getmyQian()
					}, 800)
				}, 800)
			},
			//我的钱
			async getmyQian() {
				let res = await this.$api.post(global.apiUrls.myjinbi)
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.myJinBi = res.data.data
				if (this.myJinBi.is_binding_en_card == 1) {
					this.getxinxi()
				}
			},
			//获取欧洲银行绑定信息
			async getxinxi() {
				let res = await this.$api.post(global.apiUrls.a647d81eb987a0, {
					account_type: 4,
				})
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.xinxi = res.data.data
				this.yinhangname = this.xinxi.cardname
				this.name = this.xinxi.account_id
				this.bankName = this.xinxi.true_name
				this.bankCardNumber = this.xinxi.cardbank
				console.log(this.xinxi, 'this.xinxi')
			},
			//解绑
			async jiebang() {
				let res = await this.$api.post(global.apiUrls.a647d81f92e8a5, {
					account_id: this.xinxi.id,
				})
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.$message.info(res.data.msg)
				location.reload();
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(246, 246, 246, 1);
		background-size: 100% auto !important;
	}

	.bindBankC_flex_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.bindBankC_fd0_0_c1_c0 {
		font-size: 36rpx;
		font-weight: 500;
		color: #333;
	}

	.bindBankC_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #333;
	}

	.bindBankC_fd0_0_c0 {
		width: 180rpx;
	}

	.bindBankC_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
	}

	.bindBankC_flex_1 {
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		background-size: 100% auto !important;
	}

	.bindBankC_fd1_1_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.bindBankC_fd1_1_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.bindBankC_fd1_0_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.bindBankC_fd1_0_c0 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.bindBankC_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 32rpx 0rpx 32rpx 0rpx;
	}

	.bindBankC_flex_2 {
		background: rgba(246, 246, 246, 1);
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto !important;
	}

	.bindBankC_fd2_0 {
		background: #6A0002;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		width: 638rpx;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 700;
	}
</style>